package what.basic.basiccomponent;
import javax.swing.*;
import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

public class Jframe {
	public JFrame jframe(String str){
		JFrame f=new JFrame(str);
		Toolkit kit=Toolkit.getDefaultToolkit();
		Dimension d=kit.getScreenSize();
		int width=d.width;
		int height=d.height;
		int x=(width-f.getWidth())/2;
		int y=(height-f.getHeight())/2;
		f.setLocation(x,y);
		f.addWindowListener(new WindowAdapter(){
			public void windowClosing(WindowEvent e){
				System.exit(0);
			}
		});
		return f;
	}
	public JFrame jframe(String str,int w,int h){
		JFrame f=new JFrame(str);
		Toolkit kit=Toolkit.getDefaultToolkit();
		Dimension d=kit.getScreenSize();
		int width=d.width;
		int height=d.height;
		f.setSize(w,h);
		int x=(width-f.getWidth())/2;
		int y=(height-f.getHeight())/2;
		f.setLocation(x,y);
		f.addWindowListener(new WindowAdapter(){
			public void windowClosing(WindowEvent e){
				System.exit(0);
			}
		});
		return f;
	}
	public JFrame jframe(String str,int w,int h,boolean b){
		JFrame f=new JFrame(str);
		Toolkit kit=Toolkit.getDefaultToolkit();
		Dimension d=kit.getScreenSize();
		int width=d.width;
		int height=d.height;
		f.setSize(w,h);
		int x=(width-f.getWidth())/2;
		int y=(height-f.getHeight())/2;
		f.setLocation(x,y);
		f.setVisible(b);
		f.addWindowListener(new WindowAdapter(){
			public void windowClosing(WindowEvent e){
				System.exit(0);
			}
		});
		return f;
	}
	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
